package cn.gailvlun.gll.util

import cn.gailvlun.gll.net.Member

fun join(delimiter: CharSequence, tokens: List<Member>, onlyThree: Boolean = false): String {
    val sb = StringBuilder()
    var tempTokens: List<Member>
    tempTokens = if (onlyThree) {
        tokens.filterIndexed { index, _ ->
            index < 3
        }
    } else {
        tokens
    }
    val it = tempTokens.iterator()
    if (it.hasNext()) {
        sb.append(it.next().owner.name)
        while (it.hasNext()) {
            sb.append(delimiter)
            sb.append(it.next().owner.name)
        }
    }
    return sb.toString()
}